class Solution:
    def addBinary(self, a: str, b: str) -> str:
        ##length can be big
        ##用2进制加法正常思维即可
        len_a = len(a)
        len_b = len(b)
        Len = max(len_a, len_b) + 1
        c = ''
        tmp = 0  ##进位，tmp =  (n_a + n_b + tmp原值 ) // 2
        n_a = 0
        n_b = 0
        for pos in range(1, Len + 1):
            ##n_a = ?
            if pos <= len_a and a[-pos] == '1':
                n_a = 1
            else:
                n_a = 0
            if pos <= len_b and b[-pos] == '1':
                n_b = 1
            else:
                n_b = 0
            c = c + chr(ord('0') + (n_a + n_b + tmp) % 2)
            tmp = (n_a + n_b + tmp) // 2

        ze = 0
        c = c[::-1]
        for i in range(Len):
            if c[i] == '1':
                ze = i
                break

        c = c[ze:]

        if not '1' in c and len(c) > 1:
            return '0'
        return c